/**
 *@description Cookie设置
 *@author yhw
 */

const Cookie = {
	get(e) {
		return e ? decodeURIComponent(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*" + encodeURIComponent(e).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=\\s*([^;]*).*$)|^.*$"), "$1")) || null : null
	},
	set(name, value, time) {
		let expire = "";
		if (!value) {
			value = this.get(name);
		}
		let hours = 24;
		expire = time || new Date((new Date()).getTime() + hours * 3600000);
		expire = ";path=/;expires=" + expire.toGMTString();;
		document.cookie = name + "=" + encodeURIComponent(value) + expire;
	}
}

export default Cookie;